﻿using Bomber.TF.Common.GDI;
using Bomber.TF.GameCenter.BomberCenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bomber.TF.GameCenter.ToolCenter
{
    [Species(SpeciesType.SalamanderTool)]
    public class SalamanderTool : ToolBase
    {
        protected static ImageObject _iamge;
        static SalamanderTool()
        {
            _iamge = new ImageObject(Properties.Resources.Salamander__1_);
        }
        public SalamanderTool() : base(SpeciesType.BombTool, new Size(39, 50))
        {

        }
        private int _y = -1;
        private DateTime _time = DateTime.MinValue;
        private bool _direction = true;
        public override unsafe void Business(GameListBase* ptr)
        {
            DateTime time = DateTime.Now;
            if ((time - _time).TotalMilliseconds >= 200)
            {
                _time = time;
                if (_direction)
                {
                    if (++_y == 2)
                    {
                        _y = 0;
                        _direction = !_direction;
                    }
                }
                else
                {
                    if (--_y == -2)
                    {
                        _y = 0;
                        _direction = !_direction;
                    }
                }
            }
        }
        public override void Draw(Graphics g)
        {
            IntPtr hdc = g.GetHdc();
            var img = _iamge;
            GDI32.DrawImageTransparenc(hdc, img.BitmapPtr, Location.X + (CellWidth - Size.Width >> 1) - (int)(1 * ZoomX), Location.Y + (CellHeight - Size.Height >> 1) + (int)(_y * ZoomY), img.Width, img.Height, Size.Width, Size.Height);
            g.ReleaseHdc(hdc);
        }
        protected override void DisposeAll()
        {
            base.DisposeAll();
            _iamge.Dispose();
        }

        public override void Upgradation(BomberBase bomberBase)
        {
            bomberBase.BombRange++;
        }
    }
}
